package P1000;

import java.util.Scanner;

/**
 * @author: zhouyang
 * @descrpition:
 * @time: 2019-10-05 20:53
 */
public class P1909_买铅笔 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int res = Integer.MAX_VALUE;
        for(int i=0;i<3;++i){
            int num = scanner.nextInt();
            int val = scanner.nextInt();
            int now = n/num;
            now += n%num == 0?0:1;
            res = Math.min(res,now*val);
        }
        scanner.close();
        System.out.println(res);
    }
}
